package com.question.java.enums;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


/**
 * 资产类型枚举
 * @author YK
 * */
public enum AssetCodeEnum implements Serializable {
	/*===================个人MLS账户=====================*/
	/*现金类资产*/
	//可用
	CASH_AVAILABLE,
	//预提现
	CASH_PRE_WITHDRAW,
	//注册券
	CASH_TRANSFER,
	//借贷
	CASH_LOAN,
	//消费现金(20%)
	CASH_ONLY_CONSUME,
	//购物津贴
	CASH_SHOPPING_BONUS,
	//商城收益80%现金
	CASH_MALL_EARNINGS_CONSUME,
	/*公积金类资产*/
	//可用
	GJJ_AVAILABLE,
	//预提现
	GJJ_PRE_WITHDRAW,

	/*佣金类资产*/
	//收益奖励（推荐与注册）
	CASH_RECOMMEND,
	//业绩提成
	CASH_PERFORMANCE,

	//新增其中不可转注册券资产（包含在可转账资产中）
	CASH_NO_TRANSFER,
	
	/*送房类资产*/
	//送房业绩
	GH_PERFORMANCE,
	//送房邀请人数
	GH_RECOMMEND_COUNT,
	//送房数量
	GH_COUNT,
	
	/*业绩类*/
	//补贴业绩
	PERFORMANCE_BONUS,
	//贡献业绩
	PERFORMANCE_CONTRIBUTION,
	//总业绩
	PERFORMANCE_TEAM,
	//经理前累计业绩
	PERFORMANCE_ADD,
	//团队贡献
	PERFORMANCE_TEAM_TC,
	
	/*股权类资产*/
	//合发股权数
	STOCK_FYBANKS,
	//全球家股权数
	STOCK_GLOBAL_HOME,
	//盗铃中心股权
	STOCK_STEAL_AGE,
	//线上支付虚拟资产
	VIRTUAL_CASH,

	/*干细胞类资产*/
	//累计干细胞疗程资格
	STEMCELL_COURSE_COUNT,
	//累计送干细胞疗程资格
	STEMCELL_GIVE_COURSE_COUNT,
	//可用干细胞疗程资格
	STEMCELL_AVAILABLE_COUNT,
	//当前累计干细胞业绩
	STEMCELL_PERFORMANCE,
	//盘盈
	CASH_OVERAGE,
	// 红包
	RED_PACKET,

	// 爱心红包
	LOVE_RED_PACKET,
	/*===================个人商城账户=====================*/
	/*现金类资产*/
	//可用
	CASH_AVAILABLE_MALL,
	//押金CASH_FREEZE_MALL
	CASH_FOREGIFT_MALL,
	//冻结现金jj
	CASH_FREEZE_MALL,
	/*抵扣券类资产*/
	//可用
	INTEGRAL_AVAILABLE,
	//倍增
	INTEGRAL_DEPOSIT(1,"倍增抵扣券","incomeAssetCode"),
	//待返
	INTEGRAL_WAIT_RETURN(2,"待返抵扣券","incomeAssetCode"),
	//待激活
	INTEGRAL_WAIT_ACTIVATED(3,"待激活抵扣券","incomeAssetCode"),
	//溢出
	INTEGRAL_OVERFLOW(4,"溢出抵扣券","incomeAssetCode"),
	//挂牌
	INTEGRAL_SALE(5,"挂牌抵扣券","incomeAssetCode"),
	//授信
	INTEGRAL_SX,
	//借贷
	INTEGRAL_LOAN,
	//增值
	INTEGRAL_INCREASE,
	//容器上限
	INTEGRAL_CONTAINER_LIMIT,
	//累计推广收益
	INTEGRAL_EXTEND_PROFIT,
	//累计购买抵扣券
	INTEGRAL_BUY_ADD,
	//不可用
	INTEGRAL_AVAILABLE_NO(6,"冻结抵扣券","incomeAssetCode"),
	//累计现金下单购物金额
	INTEGRAL_CASH_ORDER_ADD,
	//累计全球家与商城的利润分配
	INTEGRAL_ASSIGN,
	/*企业现金类资产*/
	CASH_AVAILABLE_COMPANY,
	/*企业预提现资产*/
	CASH_PRE_WITHDRAW_COMPANY,
	/*全球家现金类资产*/
	CASH_GLOBAL_HOUSE_AVAILABLE_COMPANY,
	/*全球家预提现现金类资产*/
	CASH_PRE_GLOBAL_HOUSE_AVAILABLE_COMPANY,
	/*OTO现金类资产*/
	CASH_OTO_AVAILABLE_COMPANY,
	/*OTO预提现现金类资产*/
	CASH_PRE_OTO_AVAILABLE_COMPANY,
	/*===================城代、片代、县代代理账户=====================*/
	/*现金类资产   现在相当于普通用户的注册券资产*/
	/**代理注册券1（代理注册券余额=代理注册券1+代理注册券2-借贷注册券）*/
	// 一个账户可以允许城代 片代 镇代 ，因此必须区分开代理账户，20181213之前一个账户只允许一个代理
	@Deprecated
	PROXY_CASH_AVAILABLE,
	/**代理注册券2（代理注册券余额=代理注册券1+代理注册券2-借贷注册券）*/
	@Deprecated
	PROXY_CASH_UNAVAILABLE,
	/**待提现（废弃）*/
	@Deprecated
	PROXY_CASH_PRE_WITHDRAW,
	/**借贷注册券（代理注册券余额=代理注册券1+代理注册券2-借贷注册券）*/
	@Deprecated
	PROXY_CASH_LOAN,
	PROXY_CITY_CASH_AVAILABLE(1,"城代","PROXY_CITY_CASH_AVAILABLE"),
	PROXY_REGION_CASH_AVAILABLE(2,"片代","PROXY_REGION_CASH_AVAILABLE"),
	PROXY_TOWN_CASH_AVAILABLE(3,"镇代","PROXY_TOWN_CASH_AVAILABLE"),
	PROXY_CITY_PRE_CASH_WITHDRAW(1,"城代预账户","PROXY_CITY_CASH_AVAILABLE"),
	PROXY_REGION_PRE_CASH_WITHDRAW(2,"片代预账户","PROXY_REGION_CASH_AVAILABLE"),
	PROXY_TOWN_PRE_CASH_WITHDRAW(3,"镇代预账户","PROXY_TOWN_CASH_AVAILABLE"),
	PROXY_CITY_CASH_LOAN,
	PROXY_REGION_CASH_LOAN,
	PROXY_TOWN_CASH_LOAN,
	PROXY_CITY_CASH_UNAVAILABLE,
	PROXY_REGION_CASH_UNAVAILABLE,
	PROXY_TOWN_CASH_UNAVAILABLE,
	PROXY_CITY_CASH_TRANSFER_AVAILABLE(1,"城代注册券","PROXY_CITY_CASH_TRANSFER_AVAILABLE"),
	PROXY_REGION_CASH_TRANSFER_AVAILABLE(2,"片代注册券","PROXY_REGION_CASH_TRANSFER_AVAILABLE"),
	PROXY_TOWN_CASH_TRANSFER_AVAILABLE(3,"镇代注册券","PROXY_TOWN_CASH_TRANSFER_AVAILABLE"),
	PROXY_CITY_PRE_CASH_TRANSFER_WITHDRAW(1,"城代注册券预账户","PROXY_CITY_PRE_CASH_TRANSFER_AVAILABLE"),
	PROXY_REGION_PRE_CASH_TRANSFER_WITHDRAW(2,"片代注册券预账户","PROXY_REGION_PRE_CASH_TRANSFER_AVAILABLE"),
	PROXY_TOWN_PRE_CASH_TRANSFER_WITHDRAW(3,"镇代注册券预账户","PROXY_TOWN_PRE_CASH_TRANSFER_AVAILABLE"),
	PROXY_CITY_CASH_TRANSFER_LOAN,
	PROXY_REGION_CASH_TRANSFER_LOAN,
	PROXY_TOWN_CASH_TRANSFER_LOAN,
	PROXY_CITY_CASH_TRANSFER_UNAVAILABLE,
	PROXY_REGION_CASH_TRANSFER_UNAVAILABLE,
	PROXY_TOWN_CASH_TRANSFER_UNAVAILABLE,

	/*业绩类*/
	//补贴业绩
	PROXY_PERFORMANCE_BONUS,
	
	/*抵扣券类资产*/
	//可用
	PROXY_INTEGRAL_AVAILABLE,
	
	/*房产专项资产*/
	//房产注册券
	GH_SPECIAL_INTEGRAL,
	//现金
	GH_SPECIAL_CASH,
	/*房产尾款资产*/
	GH_END_PAYMENT,
	
	/*公司毛利*/
	PROFIT_COMPANY,
	/*平台毛利*/
	PROFIT,
	/*贡献公司毛利*/
	PROFIT_CONTR_COMPANY,
	/*贡献平台毛利*/
	PROFIT_CONTR,
	
	/*福利类资产*/
	//福利商品保证金
	WELFARE_GOODS_MARGIN,
	//十倍专属福利
	WELFARE_PRODUCT_HIGH_PRO_TEN,
	//爱心红包系统奖池
	LOVE_RED_PACKET_SYSTEM_BAG,
	//爱心红包用户注入奖池
	LOVE_RED_PACKET_USER_BAG;


	
	private AssetCodeEnum() {
	}
	private Integer value;
	private String label;
	private String type;
	private String name;

	private AssetCodeEnum(Integer value, String label, String type) {
		this.value = value;
		this.label = label;
		this.type = type;
		this.name=this.type;
	}

	public Integer getValue() {
		return value;
	}

	public String getLabel() {
		return label;
	}

	public String getType() {
		return type;
	}
	public String getName() {
		return this.name;
	}
	public void setName(String name){
		this.name=name;
	}

	public static AssetCodeEnum findEnum(int value,String type) {
		for (AssetCodeEnum de : values()) {
			if (de.getValue()!=null&&de.getValue() == value && type!=null && type.equals(de.getType())) {
				return de;
			}
		}
		return null;
	}
	public static AssetCodeEnum findEnum(String enumToString) {
		for (AssetCodeEnum de : values()) {
			if (de.toString().equals(enumToString)) {
				return de;
			}
		}
		return null;
	}

	public static List<AssetCodeEnum> findEnums(String type) {
		List<AssetCodeEnum> enums= new ArrayList<>();
		for (AssetCodeEnum de : values()) {
			if (de.getType()!=null &&de.getType().equals(type)) {
				enums.add(de);
			}
		}
		return enums;
	}
	public static AssetCodeEnum valueOf(Class enumType, String name) {
		AssetCodeEnum result = AssetCodeEnum.findEnum(name);//通过反射,从常量列表中查找.
		if (result != null)
			return result;
		if (name == null)
			throw new NullPointerException("Name is null");
		throw new IllegalArgumentException(//最后报无效参数异常
				"No enum constant " + enumType.getCanonicalName() + "." + name);
	}
}
